package com.kis.controller.order

import com.alibaba.fastjson.JSON
import com.kis.model.ResponseData
import com.kis.model.order.Order
import com.kis.service.order.OrderClient
import io.swagger.annotations.Api
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiImplicitParams
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RestController

/**
 * Created by wongloong on 16-12-8.
 */
@RestController
@RequestMapping("/api/order")
@Api(description = "订单操作")
class OrderController {
    @Autowired
    lateinit private var orderClient: OrderClient

    @ApiOperation("添加订单")
    @ApiImplicitParams(
            ApiImplicitParam(name = "orderNo", paramType = "query", dataType = "Long", required = true, value = "订单编号", defaultValue = "10000"),
            ApiImplicitParam(name = "totalAmount", paramType = "query", dataType = "Long", required = true, value = "订单总金额", defaultValue = "10000"),
            ApiImplicitParam(name = "payAmount", paramType = "query", dataType = "Long", required = true, value = "付款总额", defaultValue = "10000")
    )
    @RequestMapping(method = arrayOf(RequestMethod.POST))
    fun saveOrUpdate(order: Order): ResponseData {
        print(order.toString())
        return orderClient.saveOrUpdate(JSON.toJSONString(order))
    }
}